package com.nurese.service;

import com.nurese.dao.AdministratorDao;
import com.nurese.entity.Administrator;
import com.nurese.entity.Administrator;
import com.nurese.utils.BeanMapUtils;
import com.nurese.utils.MapParameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AdministratorService {
    @Autowired
    private AdministratorDao administratorDao;
    
    public int create(Administrator administrator){
        return administratorDao.create(administrator);
    }
    public int delete(Integer id){
//        Map<String,Object> map=new HashMap<>();
//        map.put("id",id);
//        return administratorDao.delete(map);

        return administratorDao.delete(MapParameter.getInstance().addId(id).getMap());
    }
    public int update(Administrator administrator){
//        Map<String,Object> map= BeanMapUtils.beanToMapForUpdate(Administrator);
//        return administratorDao.update(map);
        return administratorDao.update(MapParameter.getInstance().add(BeanMapUtils.beanToMapForUpdate(administrator)).addId(administrator.getId()).getMap());
    }
    public List<Administrator> query(Administrator administrator){
        return administratorDao.query(BeanMapUtils.beanToMap(administrator));
    }
    public int count(Administrator administrator){
        return administratorDao.count(BeanMapUtils.beanToMap(administrator));
    }
    public Administrator detail(Integer id){
        return administratorDao.detail(MapParameter.getInstance().addId(id).getMap());
    }
    public Administrator login(String username,String password){

//        Map<String,Object> map=MapParameter.getInstance().add("username",userName).add("password",password).getMap();
        return administratorDao.detail(MapParameter.getInstance().add("username",username).add("password",password).getMap());
    }
}
